package com.alibaba.algo.domain.user;

import com.alibaba.algo.cooperation.usercomponent.vo.req.user.SelectResourceActionListByRoleReqVO;
import com.alibaba.algo.cooperation.usercomponent.vo.req.user.UpdateRoleResourceActionVO;
import com.alibaba.algo.cooperation.usercomponent.vo.res.user.ResourceInfo;
import com.alibaba.algo.cooperation.usercomponent.vo.res.user.SelectResourceActionListVO;
import com.alibaba.algo.core.base.BaseDomain;
import com.alibaba.algo.dao.user.SysResourceMapper;
import com.alibaba.algo.dao.user.SysRoleResourceActionMapper;
import com.alibaba.algo.entity.user.SysRoleResourceAction;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 类SysResource.java的实现描述：资源Domain
 *
 * @author nieganggang 2021-03-12 16:08:17
 */
@Component
@Slf4j
public class SysRoleResourceActionDomain extends BaseDomain<SysRoleResourceAction> {

    @Resource
    private SysResourceMapper sysResourceMapper;
    @Resource
    private SysRoleResourceActionMapper sysRoleResourceActionMapper;


    public Long selectResourceActionIdByResourceIdActionCode(UpdateRoleResourceActionVO vo){
        return sysRoleResourceActionMapper.selectResourceActionIdByResourceIdActionCode(vo);
    };

    public Long selectRoleIdByCode(UpdateRoleResourceActionVO vo){
        return sysRoleResourceActionMapper.selectRoleIdByCode(vo);
    }
/*
    public int insert(UpdateRoleResourceActionVO vo){
        int result=sysRoleResourceActionMapper.insert(vo);
        return result;
    }

 */

    public int deleteListByRole(UpdateRoleResourceActionVO vo){
        return sysRoleResourceActionMapper.deleteListByRole(vo);
    }

    public int delete(UpdateRoleResourceActionVO vo){
        return sysRoleResourceActionMapper.delete(vo);
    }

    public int deleteByActionIdAndAppCode(SysRoleResourceAction action){
        return sysRoleResourceActionMapper.deleteByActionIdAndAppCode(action);
    }


    public List<ResourceInfo> selectResourceListAll(String appCode) {
        return sysRoleResourceActionMapper.selectResourceListAll(appCode);
    }

    public List<SelectResourceActionListVO> selectResourceActionListAll(String appCode){
        List<SelectResourceActionListVO> result = sysRoleResourceActionMapper.selectResourceActionListAll(appCode);
        if(result==null){
            log.info("SysRoleResourceActionDomain selectResourceActionListAll result data is null");
        };
        return result;
    }

    public List<SelectResourceActionListVO> selectResourceActionListByRoleReq(SelectResourceActionListByRoleReqVO vo){
        List<SelectResourceActionListVO> result = sysRoleResourceActionMapper.selectResourceActionListByRoleReq(vo);
        if(result==null){
            log.info("SysRoleResourceActionDomain selectResourceActionListByRoleReq result data is null");
        }
        return result;
    }

}
